import request from '@/utils/request'


/*
 *登陆
 */

export function login(loginName, password) {
    return request({
        url: '/user/login',
        method: 'post',

        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
        data: {
            type: 2,
            data: {
                loginName,
                password
            }
        }
    })
}

/*
 *登陆
 */

export function smslogin(phone, code) {
    return request({
        url: '/user/loginUseSms',
        method: 'post',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
        data: {
            type: 2,
            data: {
                phone,
                code
            }
        }
    })
}

/*
 *注册
 */


export function register(data) {
    return request({
        url: `user/register`,
        method: 'post',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
        data: {
            type: 2,
            data: data
        }
    })
}

/*
 *修改密码
 */

export function resetPwd(data) {
    return request({
        url: '/user/resetPwd',
        method: 'post',
        headers: {
            'Content-Type': 'application/json;charset=UTF-8'
        },
        data: {
            type: 2,
            data: data
        }
    })
}

/*
 *用户信息
 */

export function getInfo(token) {
    return request({
        url: '/sysUser/info',
        method: 'get',
        params: {
            token
        }
    })
}

/**
 * 退出
 */

export function logout() {
    return request({
        url: '/logOut',
        method: 'get'
    })
}

/**
 * 获取验证码
 */

export function fetchCode(params) {
    return request({
        url: '/user/SmsCode/',
        method: 'post',
        params
    })
}